using dnAnalytics.LinearAlgebra;
using NUnit.Framework;

namespace dnAnalytics.UnitTests.LinearAlgebra
{
    public class SparseVectorTest : AbstractVectorTest
    {
        public override Vector GetVector(int order)
        {
            return VectorBuilder.CreateVector(order, VectorType.Sparse);
        }

        public override Vector GetVector(int order, double value)
        {
            return VectorBuilder.CreateVector(order, value, VectorType.Sparse);
        }

        public override Vector GetVector(double[] data)
        {
            return VectorBuilder.CreateVector(data, VectorType.Sparse);
        }

        public override Matrix GetMatrix(int rows, int columns)
        {
            return MatrixBuilder.CreateMatrix(rows, columns, MatrixType.Dense);
        }
    }

    [TestFixture]
    [Category("Managed")]
    [Category("Sparse")]
    public class ManagedSparseVectorTest : SparseVectorTest
    {
        static ManagedSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = false;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Sparse;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Sparse;
        }
    }

    [TestFixture]
    [Category("Native")]
    [Category("Mkl")]
    [Category("Sparse")]
    public class MklSparseVectorTest : SparseVectorTest
    {
        static MklSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = true;
            dnAnalytics.Settings.Blas = dnAnalytics.LinearAlgebra.Native.BlasProvider.Mkl;
            dnAnalytics.Settings.Lapack = dnAnalytics.LinearAlgebra.Native.LapackProvider.Mkl;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Sparse;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Sparse;
        }
    }

    [TestFixture]
    [Category("Native")]
    [Category("Acml")]
    [Category("Sparse")]
    public class AcmlSparseVectorTest : SparseVectorTest
    {
        static AcmlSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = true;
            dnAnalytics.Settings.Blas = dnAnalytics.LinearAlgebra.Native.BlasProvider.Acml;
            dnAnalytics.Settings.Lapack = dnAnalytics.LinearAlgebra.Native.LapackProvider.Acml;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Sparse;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Sparse;
        }
    }
    
    [TestFixture]
    [Category("Native")]
    [Category("Atlas")]
    [Category("Sparse")]
    public class AtlasClapackSparseVectorTest : SparseVectorTest
    {
        static AtlasClapackSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = true;
            dnAnalytics.Settings.Blas = dnAnalytics.LinearAlgebra.Native.BlasProvider.Atlas;
            dnAnalytics.Settings.Lapack = dnAnalytics.LinearAlgebra.Native.LapackProvider.Clapack;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Sparse;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Sparse;
        }
    }

    [TestFixture]
    [Category("Managed")]
    [Category("Sparse")]
    public class ManagedDenseSparseVectorTest : SparseVectorTest
    {
        static ManagedDenseSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = false;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Dense;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Dense;
        }
    }

    [TestFixture]
    [Category("Native")]
    [Category("Mkl")]
    [Category("Sparse")]
    public class MklDenseSparseVectorTest : SparseVectorTest
    {
        static MklDenseSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = true;
            dnAnalytics.Settings.Blas = dnAnalytics.LinearAlgebra.Native.BlasProvider.Mkl;
            dnAnalytics.Settings.Lapack = dnAnalytics.LinearAlgebra.Native.LapackProvider.Mkl;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Dense;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Dense;
        }
    }

    [TestFixture]
    [Category("Native")]
    [Category("Acml")]
    [Category("Sparse")]
    public class AcmlDenseSparseVectorTest : SparseVectorTest
    {
        static AcmlDenseSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = true;
            dnAnalytics.Settings.Blas = dnAnalytics.LinearAlgebra.Native.BlasProvider.Acml;
            dnAnalytics.Settings.Lapack = dnAnalytics.LinearAlgebra.Native.LapackProvider.Acml;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Dense;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Dense;
        }
    }

    [TestFixture]
    [Category("Native")]
    [Category("Atlas")]
    [Category("Sparse")]
    public class AtlasClapackDenseSparseVectorTest : SparseVectorTest
    {
        static AtlasClapackDenseSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = true;
            dnAnalytics.Settings.Blas = dnAnalytics.LinearAlgebra.Native.BlasProvider.Atlas;
            dnAnalytics.Settings.Lapack = dnAnalytics.LinearAlgebra.Native.LapackProvider.Clapack;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Dense;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Dense;
        }
    }

    [TestFixture]
    [Category("Native")]
    [Category("AcmlIFort")]
    [Category("Dense")]
    public class AcmlIFortSparseVectorTest : DenseMatrixTest
    {
        static AcmlIFortSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = true;
            dnAnalytics.Settings.Blas = dnAnalytics.LinearAlgebra.Native.BlasProvider.Acml;
            dnAnalytics.Settings.Lapack = dnAnalytics.LinearAlgebra.Native.LapackProvider.AcmlIFort;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Dense;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Dense;
        }
    }

    [TestFixture]
    [Category("Native")]
    [Category("AcmlIFort")]
    [Category("Dense")]
    public class AcmlIFortDenseSparseVectorTest : DenseMatrixTest
    {
        static AcmlIFortDenseSparseVectorTest()
        {
            dnAnalytics.Settings.UseNativeLibrary = true;
            dnAnalytics.Settings.Blas = dnAnalytics.LinearAlgebra.Native.BlasProvider.Acml;
            dnAnalytics.Settings.Lapack = dnAnalytics.LinearAlgebra.Native.LapackProvider.AcmlIFort;
            dnAnalytics.Settings.DefaultMatrixType = MatrixType.Sparse;
            dnAnalytics.Settings.DefaultVectorType = VectorType.Sparse;
        }
    }
}